package com.bbjob.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.net.Socket;

public class SocketUser {
	private String name;
	private String account;
	private Socket socket;
	private BufferedReader br;
	private PrintWriter pw;
	private String cIp;
	private Integer examId;
	private String qId;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public Socket getSocket() {
		return socket;
	}

	public void setSocket(Socket socket) {
		this.socket = socket;
	}

	public BufferedReader getBr() {
		return br;
	}

	public void setBr(BufferedReader br) {
		this.br = br;
	}

	public PrintWriter getPw() {
		return pw;
	}

	public void setPw(PrintWriter pw) {
		this.pw = pw;
	}

	public String getcIp() {
		return cIp;
	}

	public void setcIp(String cIp) {
		this.cIp = cIp;
	}

	public Integer getExamId() {
		return examId;
	}

	public void setExamId(Integer examId) {
		this.examId = examId;
	}

	public String getqId() {
		return qId;
	}

	public void setqId(String qId) {
		this.qId = qId;
	}

	public SocketUser(String name, final Socket socket) throws IOException {
		this.name = name;
		this.socket = socket;
		// 读取客户端传输的 输入流
		this.br = new BufferedReader(new InputStreamReader(
				socket.getInputStream(), "UTF-8"));
		// 转发给客户端的 输出流
		this.pw = new PrintWriter(new OutputStreamWriter(
				socket.getOutputStream(), "UTF-8"), true);
	}

	@Override
	public String toString() {
		return "SocketUser{" + "name='" + name + '\'' + ", account='" + account
				+ '\'' + ", socket=" + socket + '}';
	}
}
